package com.yuyu.service.impl;

import com.yuyu.bean.Order;
import com.yuyu.mapper.OrderMapper;
import com.yuyu.service.OrderItemService;
import com.yuyu.service.OrderService;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;


class OrderServiceImplTest {

    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
    OrderService orderService = (OrderService) applicationContext.getBean("orderService");



    @Test
    void findOrderById() {

        Order order = orderService.findOrderById(1);
        System.out.println(order);
//        System.out.println(orderMapper);
    }

    @Test
    void addOrder(){
        Order order = new Order();
        order.setId(6);
        System.out.println(orderService.addOrder(order));
    }

    @Test
    void deleteOrder(){
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        System.out.println(orderService.deleteOrder(list));

    }

    @Test
    void getLastId(){
        Integer lastId = orderService.getLastId();
        System.out.println(lastId);
    }
}